<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>返回用数字时钟格式的时间</title>
</head>
<body>
	<script type="text/javascript">
		// 6:27:35 P.M.
		// 6:30:01 P.M.
		// 6:04:01 A.M.
		// :0    4
		//  :   30
		
		function nowNumTime(){
			var now = new Date();
			var hour  = now.getHours(); //0 ~ 23.   //19
			var minute = now.getMinutes();
			var second = now.getSeconds();
			// 18 > 12  ? 18-12  : 8
			var temp = '' + (hour > 12 ?  hour - 12 : hour);
			if(hour === 0){
				temp = '12';
			}
			temp  = temp +(minute < 10 ?  ':0': ":")+ minute;
			temp  = temp +(second < 10 ?  ':0': ":")+ second;
			temp = temp + (hour >= 12 ?  ' P.M.': " A.M.");
			return temp;
		}
		var nownum = nowNumTime();
		console.log(nownum);
	</script>
	
</body>
</html>